home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: const pointer confusion...
- Date: 25 Mar 1996 06:21:08 -0600
- Organization: none
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4j633k$3dp@solutions.solon.com>
- References: <4j06gm$7oa@solutions.solon.com>
- Reply-To: fred@genesis.demon.co.uk
- NNTP-Posting-Host: solutions.solon.com
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4j06gm$7oa@solutions.solon.com>
- mangino@planet.net "Reed R. Mangino" writes:
-
- >Could someone please straighten me out on this:
- >
- >1) const int *p = 10;
- > p is a constant pointer to an int, right?
-
- No, it is a pointer to const int.
-
- >While p can be made to
- > point to something else, *p can never be assigned to, right?
-
- That, however, is correct.
-
- >2) int *const p;
-
- This is a const pointer to int.
-
- > p is a pointer to an integer. *p can be assigned to, but p can
- > never be made to point to another address in memory, right?
-
- Yes.
-
- >3) int const *p;
- > What the heck is this? I can't find anything like this in my
- > books, but my compiler thinks everything is hunky doory!???
-
- It means the same thing as const int *p; Qualifiers (const or volatile)
- can appear before or after the type specifier (int in this case) that they
- refer to. If they refer to a pointer they must appear after the relevant *.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-